#define cddHeader()
<style>
	#cdd-nav {
		border: 0; 
	}
	
	#cdd-nav li a {
		padding: 12px;
    	font-size: 16px;
	}
	#twonav .message {
		position: relative;
	}
	#twonav .message span {
		display: none;
		position: absolute;
		top: -12px;
		right: -9px;
		padding: 0 5px;
		border-radius: 20px;
		height: 17px;
		line-height: 18px;
		background-color: #f00;
		color: #fff;
		text-align: center;
	}
</style>
<div id="headbody" class="nav tabwell">
	<div class="logomdl">
		<div class="col-md-3">
			<a href="/admin" style="display: inline-block;padding: 10px 0;width: 38%;">
				<img src="/assets/img/logo.png" style="width: 100%;">
			</a>
			<span style="font-size: 16px;margin-left: 20px;vertical-align: text-top;">车抵贷业务系统</span>
		</div>
		<div class="col-md-6">
			<ul class="nav nav-tabs nav-menue" id="cdd-nav">
				#for(item:user.allowList)
				<li class="#(tableType==item.tableType?'active':'')"><a
					href="#(item.actionKey==''?'javascript:;':item.actionKey)">#(item.pageName)</a></li>
				#end
			</ul>
		</div>
		<div class="col-md-3" id="twonav" style="margin-top: 14px;padding-right: 45px; text-align: right;">
			<a href="/admin">首页</a>
			<a href="javascript:;" id="usercenter" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">个人中心</a>
			<ul class="dropdown-menu" aria-labelledby="usercenter">
			    <li><a href="javascript:;" id="resetpas">修改密码</a></li>
			</ul>
			<a href="javascript:;" class="message">消息通知<span></span></a>
			<a href="javascript:;">其他</a>
			<a href="/admin/logout">注销</a>
			<div id="message"></div>
		</div>
	</div>
</div>
<script>
	$(function(){
		var alert_confirm = $("#alert_confirm")
		alert_confirm.find("button.confirm").attr("subtype",0)
		$("#resetpas").click(function(){
			var opt = {
				isShowBg: false,
				text: "<div style='margin-bottom: 10px;'><a href='javascript:;' class='changebtn' style='font-size: 14px;margin-right: 10px;'>原密码修改</a><a href='javascript:;' class='changebtn' style='font-size: 14px;'>短信修改</a></div>"+
					  "<div class='selbox'>"+
					  "    <div class='box active' style='width: 50%;margin: 0 auto;'>"+
					  "        <div><input class='form-control oldpas' type='password' placeholder='原密码' /></div>"+
					  "        <div><input style='margin: 10px 0;' class='form-control newpas' type='password' placeholder='新密码' /></div>"+
					  "        <div><input class='form-control reaptepas' type='password' placeholder='确认密码' /></div>"+
					  "	       <p class='err' style='color: #a94442;margin: 0;font-size: 16px;line-height: 38px;'></p>"+
					  "    </div>"+
					  "    <div class='box' style='display: none;width: 50%;margin: 0 auto;'>"+
					  "        <div class='input-group'><input class='form-control phone' style='border-radius: 4px 0 0 4px;' type='type' placeholder='手机号码' /><span class='input-group-btn'><button class='btn btn-default getyzm-hook' style='border-radius: 0px 4px 4px 0;' type='button' data-loading-text='正在发送...'>获取验证码</button></span></div>"+
					  "        <div><input style='margin: 10px 0;' class='form-control yzm' type='type' placeholder='短信验证码' /></div>"+
					  "        <div><input style='margin: 10px 0;' class='form-control newpas' type='password' placeholder='新密码' /></div>"+
					  "        <div><input class='form-control reaptepas' type='password' placeholder='确认密码' /></div>"+
					  "	       <p class='err' style='color: #a94442;margin: 0;font-size: 16px;line-height: 38px;'></p>"+
					  "    </div>"+
					  "</div>",
				fn: function(modalDom,btn,callback){
					if(yz(modalDom.find(".modal-body").find(".active").find("input"))){
						var data = {}
						data.password = modalDom.find(".active").find("input.oldpas").val();//原密码
						data.password1 = modalDom.find(".active").find("input.newpas").val()//新密码
						data.password2 = modalDom.find(".active").find("input.reaptepas").val()//重复新密码
						if(btn.attr("subtype") == 1){
							data.yzm = modalDom.find("input.yzm").val()
							data.password = modalDom.find(".active").find("input.newpas").val()
							axios.post("/adminLogin/setPassWord",_x.qsStringify(data))
							.then(function(res){
								console.log(res)
								if(res.data.code == 1){
									callback()
									_x.show_alert_sh(res.data.msg,true)
								}else{
									_x.show_alert_sh(res.data.msg,false)
								}
								btn.button('reset')
							})
							.catch(function(){
								_x.show_alert_sh("修改失败！",false)
								btn.button('reset')
							})
						}else{
							//先验证原密码
							axios.post("/adminLogin/checkPassword ",_x.qsStringify(data))
							.then(function(res){
								console.log(res.data)
								if(res.data.code == 1){
									axios.post("/adminLogin/resetPassWord",_x.qsStringify(data))
									.then(function(res2){
										console.log(res2.data)
										if(res2.data.code == 1){
											callback()
											_x.show_alert_sh(res2.data.msg,true)
										}else{
											_x.show_alert_sh(res2.data.msg,false)
										}
										btn.button('reset')
									})
									.catch(function(){
										_x.show_alert_sh("修改失败！",false)
										btn.button('reset')
									})		
								}else{
									modalDom.find("input.oldpas").parent().addClass("has-error")
									modalDom.find(".active").children(".err").text(res.data.msg)
									btn.button('reset')
								}
							})
							.catch(function(){
								_x.show_alert_sh("修改失败！",false)
								btn.button('reset')
							})
						}
						
					}else{
						btn.button('reset')
					}
				}
			}
			_x.show_alert_confirm(opt)
		})
		
		//0原密码 1短信
		alert_confirm.on("click",".changebtn",function(){
			var index = $(this).index()
			alert_confirm.find(".selbox").children(".box").removeClass("active").hide().eq(index).addClass("active").show()
			alert_confirm.find("button.confirm").attr("subtype",index)
		})
		
		//获取验证码
		alert_confirm.on("click",".getyzm-hook",function(){
			var that = $(this)
			
			if(yz(that.parent().siblings("input"))){
				that.button('loading')
				var data = {}
				data.userPhone = that.parent().siblings("input").val()
				axios.post("/adminLogin/getForgetCode",_x.qsStringify(data))
				.then(function(res){
					if(res.data.code == 1){
						countDown(that)
					}else{
						_x.show_alert_sh(res.data.msg,false)
						that.button('reset')
					}
				})
				.catch(function(){
					_x.show_alert_sh("验证码发送失败！",false)
					that.button('reset')
				})
			}
			
			
		})
		
		function countDown(dom){
			var timer = null,
				second = 120
			timer = setInterval(function(){
				second--
				dom.text(second + "s后重新发送")
				if(second <= 0){
					dom.button('reset').text("获取验证码")
					clearInterval(timer)
				}
			},1000)
		}
		
		function yz(input){
			var mark = true
			input.each(function(){
				var that = $(this),
					val = that.val(),
					errDom = that.parents(".active").children(".err")
				if(_x.isEmpty(val)){
					mark = false
					errDom.text(that.attr("placeholder") + "不能为空！")
					that.parent().addClass("has-error")
				}else{
					that.parent().removeClass("has-error")
				}
				
				if(that.hasClass("newpas")){
					if(val != that.parents(".active").find(".reaptepas").val()){
						mark = false
						errDom.text("两次密码不一致！")
						that.parent().addClass("has-error")
					}
				}
				
				if(that.hasClass("reaptepas")){
					if(val != that.parents(".active").find(".newpas").val()){
						mark = false
						errDom.text("两次密码不一致！")
						that.parent().addClass("has-error")
					}
				}
			})
			
			return mark
		}
		
		/*var websocket = null;
	       
      //判断当前浏览器是否支持WebSocket
	  if('WebSocket' in window){
          websocket = new WebSocket("ws://localhost:80/webScoket");
      }
      else{
          alert('Not support websocket')
      }
       
      //连接发生错误的回调方法
      websocket.onerror = function(){
          setMessageInnerHTML("error");
      };
       
      //连接成功建立的回调方法
      websocket.onopen = function(event){
          setMessageInnerHTML("open");
          websocket.send("发送数据");
      }
       
      //接收到消息的回调方法
      websocket.onmessage = function(event){
    	  console.log(event)
          setMessageInnerHTML(event.data);
      }
       
      //连接关闭的回调方法
       websocket.onclose = function(){
          setMessageInnerHTML("close"); 
      }
       
      //监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。
      window.onbeforeunload = function(){
          websocket.close();
      }
       
      //将消息显示在网页上
      function setMessageInnerHTML(innerHTML){
          document.getElementById('message').innerHTML += innerHTML + '<br/>';
      }
       
      //关闭连接
      function closeWebSocket(){
          websocket.close();
      }
       
      //发送消息
       function send(){
          var message = document.getElementById('text').value;
          websocket.send(message);
      } */
	})
</script>
<!-- <div id="headbody" class="headbody nav tabwell"> -->
<!-- 	<div class="logomdl"> -->
<!-- 		<div class="col-md-2"> -->
<!-- 			<a href="/admin" style="display: block;"><img -->
<!-- 				src=" /assets/img/logo.png" style="height: 50px; buttom: 0px;"></a> -->
<!-- 		</div> -->
<!-- 		<div class="col-md-4"> -->
<!-- 			<h3 style="margin: 0; line-height: 51px;">人车人车贷管理系统</h3> -->
<!-- 		</div> -->
<!-- 		<div class="col-md-6" style="padding-right: 45px; text-align: right;"> -->
<!-- 			<a href="/admin">首页</a> <a href="javascript:;">个人中心</a> <a -->
<!-- 				href="javascript:;">消息通知</a> <a href="javascript:;">其他</a> <a -->
<!-- 				href="/admin/logout">注销</a> -->
<!-- 		</div> -->
<!-- 	</div> -->
<!-- </div> -->
#end
